/*
 * virtualdeviceconfig.cpp
 *
 *  Created on: 10/01/2012
 *      Author: rbender
 */

#include "virtualdeviceconfig.h"
#include "virtualdeviceexception.h"
#include <libxml++/libxml++.h>
#include <iostream>

using namespace xvd;
using namespace std;
using namespace xmlpp;

std::auto_ptr<VirtualDeviceConfig> VirtualDeviceConfig::m_instance;

VirtualDeviceConfig* VirtualDeviceConfig::GetInstance()
{
    if (m_instance.get() == NULL) m_instance.reset(new VirtualDeviceConfig());
    return m_instance.get();
}

VirtualDeviceConfig::VirtualDeviceConfig() :
    m_configurationfile("xvd-default.xml")
{
    try
    {
        DomParser parser;
        parser.parse_file(m_configurationfile);

        if (parser)
        {
            Node* rootnode = parser.get_document()->get_root_node();
        }
    }
    catch (const std::exception& ex)
    {
        throw;
    }

}

void VirtualDeviceConfig::ValidateVariable(const VirtualDeviceVariable* variable)
{
    if(variable->name().empty())
        throw VirtualDeviceException(VirtualDeviceException::SyntaxError, "EMPTY VARIABLE NAME DETECTED");
}

void VirtualDeviceConfig::ValidateDevice(const VirtualDevice* devicePtr)
{

}

